package so.wy.servicecenter.businessbed.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;

import so.wy.servicecenter.base.exception.WebException;
import so.wy.servicecenter.base.frame.api.httpexception.HttpExceptionHandler;
import so.wy.servicecenter.base.frame.baseopt.BaseOptHttp;
import so.wy.servicecenter.base.frame.baseopt.BaseOptWeb;
import so.wy.servicecenter.businessbed.web.DepositWeb;
import so.wy.servicecenter.businessbed.service.deposit.DepositDTO;


/**
* @author wdl
* @date 2020-04-26
*/
@RestController
@Scope("request")
@RequestMapping("/deposit")
public class DepositHttp extends BaseOptHttp<DepositDTO>  {
    @Autowired
    private DepositWeb depositWeb;

	@Override
    protected BaseOptWeb getOptWeb() {
        return depositWeb;
    }

    @HttpExceptionHandler
    @GetMapping("/open")
    public String getOpenDeposit() throws WebException{
	    return toHttpJson(depositWeb.getOpenDeposit());
    }

    @HttpExceptionHandler
    @PostMapping("/toggle")
    public String toggle(Long id){
	    depositWeb.toggle(id);
	    return toHttpJson();
    }
}